package com.four.bmm.controller;

import com.four.bmm.entity.News;
import com.four.bmm.entity.Reply;
import com.four.bmm.entity.User;
import com.four.bmm.service.ReplyService;
import com.four.bmm.util.DateUtil;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@WebServlet("/ReplyServlet")
public class ReplyServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        int newsid = Integer.parseInt(req.getParameter("newsid"));
        int rid = Integer.parseInt(req.getParameter("rid"));
        int sbid = Integer.parseInt(req.getParameter("id"));
        String contents = req.getParameter("contents");
        HttpSession session = req.getSession();
        User user = (User) session.getAttribute("liginuser");
        String pushTime = DateUtil.getCurrTime();
        Reply reply = new Reply();
        reply.setAnswerid(user);
        reply.setNewsid(new News(newsid));
        reply.setRcontent(contents);
        reply.setSbid(new User(sbid));
        reply.setReplytime(pushTime);
        ReplyService replyService = new ReplyService();
        /* boolean  flag=replyService.*/


    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }
}
